package com.dts.project.dao;
	import java.sql.*; 
	import com.dts.core.dao.AbstractDataAccessObject;
	import com.dts.core.util.CoreList;
	import com.dts.core.util.LoggerManager;
	import com.yourcompany.struts.form.MobileOperatorMasterForm;

	public class MobileOperatorMasterDao extends AbstractDataAccessObject 
	{
		public boolean insertMobileOperatorMaster(MobileOperatorMasterForm moform)
		{
			java.sql.Connection con=null;
			boolean flag=false;
			try
			{
			int n=getSequenceID("MobileOperatorMaster","OperatorId");
			con=getConnection();
			PreparedStatement ps=con.prepareStatement("insert into MobileOperatorMaster values(?,?,?)");
			ps.setInt(1,n);
			ps.setString(2,moform.getOperatorName());
			ps.setString(3,moform.getOperatorDesc());
			 
			 
			int i=ps.executeUpdate();
			if(i>0)
				flag=true;
			 
				
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}finally
		{
			try{
				con.close();
			}
		catch(Exception e)
		{
			LoggerManager.writeLogInfo(e);
		}
		}
		return flag;
		
		
			}

	public CoreList ViewMobileOperatorMaster()
	{   CoreList v=new CoreList();
		java.sql.Connection con=null;
		MobileOperatorMasterForm moform=null;
		try
		{
			con=getConnection();
			Statement st=con.createStatement();
			ResultSet rs=st.executeQuery("select * from MobileOperatorMaster");
			 
			while(rs.next())
			{
				moform=new MobileOperatorMasterForm();
				moform.setOperatorId(rs.getInt(1));
				moform.setOperatorName(rs.getString(2));
				moform.setOperatorDesc(rs.getString(3));
				 
	            v.add(moform);
			}

			 
		}
			catch(Exception e)
		{
			
		}
			finally
			{
				try{
					con.close();
				}
			catch(Exception e)
			{
				LoggerManager.writeLogInfo(e);
			}
			}
			return v;
			
		
	}
	public MobileOperatorMasterForm ViewMobileOperatorMasterById(int OperatorId)
	{   MobileOperatorMasterForm moform=new MobileOperatorMasterForm();
		java.sql.Connection con=null;
		 
		try
		{
			 
			con=getConnection();
			 
			PreparedStatement ps=con.prepareStatement("select * from MobileOperatorMaster where OperatorId = ? ");
			ps.setInt(1,OperatorId);
			ResultSet rs=ps.executeQuery();
			 
			if(rs.next())
			{
				moform=new MobileOperatorMasterForm();
				moform.setOperatorId(rs.getInt(1));
				moform.setOperatorName(rs.getString(2));
				moform.setOperatorDesc(rs.getString(3));
				 
				 
				 
			}

			 
		}
			catch(Exception e)
		{
			
		}finally
		{
			try{
				con.close();
			}
		catch(Exception e)
		{
			LoggerManager.writeLogInfo(e);
		}
		}
		return moform;
		
		
	}

	public boolean deleteMobileOperatorMaster(int OperatorId)
		{
			java.sql.Connection con=null;
			boolean flag=false;
			try
			{
				 
				con=getConnection();
				 
				PreparedStatement ps=con.prepareStatement("delete from MobileOperatorMaster where OperatorId = ? ");
				ps.setInt(1,OperatorId);
				int i=ps.executeUpdate();
				if(i>0)
					flag=true;
				
				          
			}
			catch(Exception e)
			{
			}
			finally
			{
				try{
					con.close();
				}
			catch(Exception e)
			{
				LoggerManager.writeLogInfo(e);
			}
			}
			return flag;
			
			}

	public boolean UpdateMobileOperatorMaster(MobileOperatorMasterForm moform)
	{
		java.sql.Connection con=null;
		boolean flag=false;
		try
		{
		 
		con=getConnection();
		PreparedStatement ps=con.prepareStatement("update MobileOperatorMaster set Operatorname = ?,Operatordesc = ? where OperatorId = ? ");
		ps.setInt(3,moform.getOperatorId());
		ps.setString(1,moform.getOperatorName());
		ps.setString(2,moform.getOperatorDesc());
		int i=ps.executeUpdate();
		if(i>0)
			flag=true;
		 
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}finally
	{
		try{
			con.close();
		}
	catch(Exception e)
	{
		LoggerManager.writeLogInfo(e);
	}
	}
	return flag;


		}
	}






	 


	 



